#include<bits/stdc++.h>
using namespace std;
const int N=1405,mod=998244353;
int n,m,x[N],r[N],g[N],f[N],id[N];
inline int Inv(int x){
	int ans=1;
	for(int y=mod-2;y;y>>=1,x=1ll*x*x%mod) if(y&1) ans=1ll*ans*x%mod;
	return ans;
}
int main(){
	freopen("traffic.in","r",stdin);
	freopen("traffic.out","w",stdout);
	cin>>n;
	int lcm=1;
	for(int i=1;i<=n;++i){
		int a,b,c;
		cin>>a>>b>>c;
		if(b){
			id[++m]=i;
			x[m]=a,r[m]=b,g[m]=b+c;
			lcm=1ll*lcm*g[m]/__gcd(lcm,g[m]);
		}
	}
	id[m+1]=n+1;
	for(int t=0;t<lcm;++t){
		bool flag=1;
		for(int i=1;i<=m;++i)
			if((t+x[i])%g[i]<r[i]){
				++f[i];
				flag=0;
				break;
			}
		f[m+1]+=flag;
	}
	int inv=Inv(lcm);
	for(int i=1,p=1;i<=n+1;++i){
		if(i==id[p]) cout<<1ll*f[p]*inv%mod<<'\n',++p;
		else cout<<0<<'\n';
	}
	return 0;
}


